@@ -491,3 +491,82 @@ def test_propose_with_added_files_using_add_all(fixture_tarfile, code_resource):
491
491
"Content-Type" : "application/json" ,
492
492
},
493
493
)
494
+
495
+
496
+ def test_propose_with_proposal_properties (fixture_tarfile , code_resource ):
497
+ test_download (fixture_tarfile , code_resource )
498
+
499
+ with open (f"{ folder } /README.md" , "w" ) as f :
500
+ f .write ("Content\n " )
501
+
502
+ # Mock client response
503
+ response_mock = MagicMock ()
504
+ response_mock .status_code = 204
505
+ response_mock .is_error = False
506
+
507
+ code_resource ._client ._client .request .return_value = response_mock
508
+
509
+ code_resource .propose (
510
+ {
511
+ "proposal" : {"title" : "PR title" , "body" : "PR body" },
512
+ "task" : {"id" : 28 , "token" : "abcdef" },
513
+ }
514
+ )
515
+
516
+ # Hits the API
517
+ code_resource ._client ._client .request .assert_called_once_with (
518
+ "post" ,
519
+ "/code/propose" ,
520
+ json = {
521
+ "task" : {"id" : 28 , "token" : "abcdef" },
522
+ "proposal" : {
523
+ "title" : "PR title" ,
524
+ "body" : "PR body" ,
525
+ "token" : "ghijkl" ,
526
+ "diff" : "diff --git a/README.md b/README.md\n index e69de29..39c9f36 100644\n --- a/README.md\n +++ b/README.md\n @@ -0,0 +1 @@\n +Content\n " ,
527
+ },
528
+ },
529
+ headers = {
530
+ "Accept" : "application/json" ,
531
+ "Content-Type" : "application/json" ,
532
+ },
533
+ )
534
+
535
+
536
+ def test_propose_with_metadata (fixture_tarfile , code_resource ):
537
+ test_download (fixture_tarfile , code_resource )
538
+
539
+ with open (f"{ folder } /README.md" , "w" ) as f :
540
+ f .write ("Content\n " )
541
+
542
+ # Mock client response
543
+ response_mock = MagicMock ()
544
+ response_mock .status_code = 204
545
+ response_mock .is_error = False
546
+
547
+ code_resource ._client ._client .request .return_value = response_mock
548
+
549
+ code_resource .propose (
550
+ {
551
+ "task" : {"id" : 28 , "token" : "abcdef" },
552
+ "metadata" : {"cost" : 0.1 , "random" : "yes" },
553
+ }
554
+ )
555
+
556
+ # Hits the API
557
+ code_resource ._client ._client .request .assert_called_once_with (
558
+ "post" ,
559
+ "/code/propose" ,
560
+ json = {
561
+ "task" : {"id" : 28 , "token" : "abcdef" },
562
+ "proposal" : {
563
+ "token" : "ghijkl" ,
564
+ "diff" : "diff --git a/README.md b/README.md\n index e69de29..39c9f36 100644\n --- a/README.md\n +++ b/README.md\n @@ -0,0 +1 @@\n +Content\n " ,
565
+ },
566
+ "metadata" : {"cost" : 0.1 , "random" : "yes" },
567
+ },
568
+ headers = {
569
+ "Accept" : "application/json" ,
570
+ "Content-Type" : "application/json" ,
571
+ },
572
+ )
0 commit comments