diff --git a/Pipfile.lock b/Pipfile.lock index fbf3d19be..d4fedafbc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -50,19 +50,19 @@ }, "boto3": { "hashes": [ - "sha256:d47a68a0ca6599e8711c7da670fbac24085d9d50cfb4f761204f154d2b6fae26", - "sha256:f0a78f94a7140b60960898fd86677e4e73cc96bd7f3e5c64fc5cc1818d04c7b8" + "sha256:152def2fcc9854dcc42383d2b53e2ed2c9ccb5ff6cc0f3ada20f1ab54418ede4", + "sha256:a5d6fdcaec863bc7ad2f8133ff9a926d6f06468b83b5fb631cd90bd33b709c45" ], "markers": "python_version >= '3.7'", - "version": "==1.26.138" + "version": "==1.26.141" }, "botocore": { "hashes": [ - "sha256:31edc237088c104f7a05887646bbec31d7459dd2e108fd90cbffa315902817e2", - "sha256:3d145f30d10a9c712acee48e7ce906c9456bb25fe50d477c9312c702ccfa50d1" + "sha256:b01d156c42765f3f437959e01a8c7f3cb0e29b24aa0b8f373498133408b2e3c7", + "sha256:e86e1633f98838317b9e1b5c874c4d85339b77f6b7e55c2a4d83913f6166f9ad" ], "markers": "python_version >= '3.7'", - "version": "==1.29.138" + "version": "==1.29.141" }, "cachetools": { "hashes": [ @@ -235,7 +235,7 @@ "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df", "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab" ], - "markers": "python_version >= '3.7'", + "markers": "python_full_version >= '3.7.0'", "version": "==3.1.0" }, "click": { @@ -248,60 +248,60 @@ }, "coverage": { "hashes": [ - "sha256:0342a28617e63ad15d96dca0f7ae9479a37b7d8a295f749c14f3436ea59fdcb3", - "sha256:066b44897c493e0dcbc9e6a6d9f8bbb6607ef82367cf6810d387c09f0cd4fe9a", - "sha256:10b15394c13544fce02382360cab54e51a9e0fd1bd61ae9ce012c0d1e103c813", - "sha256:12580845917b1e59f8a1c2ffa6af6d0908cb39220f3019e36c110c943dc875b0", - "sha256:156192e5fd3dbbcb11cd777cc469cf010a294f4c736a2b2c891c77618cb1379a", - "sha256:1637253b11a18f453e34013c665d8bf15904c9e3c44fbda34c643fbdc9d452cd", - "sha256:292300f76440651529b8ceec283a9370532f4ecba9ad67d120617021bb5ef139", - "sha256:30dcaf05adfa69c2a7b9f7dfd9f60bc8e36b282d7ed25c308ef9e114de7fc23b", - "sha256:338aa9d9883aaaad53695cb14ccdeb36d4060485bb9388446330bef9c361c252", - "sha256:373ea34dca98f2fdb3e5cb33d83b6d801007a8074f992b80311fc589d3e6b790", - "sha256:38c0a497a000d50491055805313ed83ddba069353d102ece8aef5d11b5faf045", - "sha256:40cc0f91c6cde033da493227797be2826cbf8f388eaa36a0271a97a332bfd7ce", - "sha256:4436cc9ba5414c2c998eaedee5343f49c02ca93b21769c5fdfa4f9d799e84200", - "sha256:509ecd8334c380000d259dc66feb191dd0a93b21f2453faa75f7f9cdcefc0718", - "sha256:5c587f52c81211d4530fa6857884d37f514bcf9453bdeee0ff93eaaf906a5c1b", - "sha256:5f3671662dc4b422b15776cdca89c041a6349b4864a43aa2350b6b0b03bbcc7f", - "sha256:6599bf92f33ab041e36e06d25890afbdf12078aacfe1f1d08c713906e49a3fe5", - "sha256:6e8a95f243d01ba572341c52f89f3acb98a3b6d1d5d830efba86033dd3687ade", - "sha256:706ec567267c96717ab9363904d846ec009a48d5f832140b6ad08aad3791b1f5", - "sha256:780551e47d62095e088f251f5db428473c26db7829884323e56d9c0c3118791a", - "sha256:7ff8f3fb38233035028dbc93715551d81eadc110199e14bbbfa01c5c4a43f8d8", - "sha256:828189fcdda99aae0d6bf718ea766b2e715eabc1868670a0a07bf8404bf58c33", - "sha256:857abe2fa6a4973f8663e039ead8d22215d31db613ace76e4a98f52ec919068e", - "sha256:883123d0bbe1c136f76b56276074b0c79b5817dd4238097ffa64ac67257f4b6c", - "sha256:8877d9b437b35a85c18e3c6499b23674684bf690f5d96c1006a1ef61f9fdf0f3", - "sha256:8e575a59315a91ccd00c7757127f6b2488c2f914096077c745c2f1ba5b8c0969", - "sha256:97072cc90f1009386c8a5b7de9d4fc1a9f91ba5ef2146c55c1f005e7b5c5e068", - "sha256:9a22cbb5ede6fade0482111fa7f01115ff04039795d7092ed0db43522431b4f2", - "sha256:a063aad9f7b4c9f9da7b2550eae0a582ffc7623dca1c925e50c3fbde7a579771", - "sha256:a08c7401d0b24e8c2982f4e307124b671c6736d40d1c39e09d7a8687bddf83ed", - "sha256:a0b273fe6dc655b110e8dc89b8ec7f1a778d78c9fd9b4bda7c384c8906072212", - "sha256:a2b3b05e22a77bb0ae1a3125126a4e08535961c946b62f30985535ed40e26614", - "sha256:a66e055254a26c82aead7ff420d9fa8dc2da10c82679ea850d8feebf11074d88", - "sha256:aa387bd7489f3e1787ff82068b295bcaafbf6f79c3dad3cbc82ef88ce3f48ad3", - "sha256:ae453f655640157d76209f42c62c64c4d4f2c7f97256d3567e3b439bd5c9b06c", - "sha256:b5016e331b75310610c2cf955d9f58a9749943ed5f7b8cfc0bb89c6134ab0a84", - "sha256:b9a4ee55174b04f6af539218f9f8083140f61a46eabcaa4234f3c2a452c4ed11", - "sha256:bd3b4b8175c1db502adf209d06136c000df4d245105c8839e9d0be71c94aefe1", - "sha256:bebea5f5ed41f618797ce3ffb4606c64a5de92e9c3f26d26c2e0aae292f015c1", - "sha256:c10fbc8a64aa0f3ed136b0b086b6b577bc64d67d5581acd7cc129af52654384e", - "sha256:c2c41c1b1866b670573657d584de413df701f482574bad7e28214a2362cb1fd1", - "sha256:cf97ed82ca986e5c637ea286ba2793c85325b30f869bf64d3009ccc1a31ae3fd", - "sha256:d1f25ee9de21a39b3a8516f2c5feb8de248f17da7eead089c2e04aa097936b47", - "sha256:d2fbc2a127e857d2f8898aaabcc34c37771bf78a4d5e17d3e1f5c30cd0cbc62a", - "sha256:dc945064a8783b86fcce9a0a705abd7db2117d95e340df8a4333f00be5efb64c", - "sha256:ddc5a54edb653e9e215f75de377354e2455376f416c4378e1d43b08ec50acc31", - "sha256:e8834e5f17d89e05697c3c043d3e58a8b19682bf365048837383abfe39adaed5", - "sha256:ef9659d1cda9ce9ac9585c045aaa1e59223b143f2407db0eaee0b61a4f266fb6", - "sha256:f6f5cab2d7f0c12f8187a376cc6582c477d2df91d63f75341307fcdcb5d60303", - "sha256:f81c9b4bd8aa747d417407a7f6f0b1469a43b36a85748145e144ac4e8d303cb5", - "sha256:f99ef080288f09ffc687423b8d60978cf3a465d3f404a18d1a05474bd8575a47" + "sha256:004948e296149644d208964300cb3d98affc5211e9e490e9979af4030b0d6473", + "sha256:13cde6bb0e58fb67d09e2f373de3899d1d1e866c5a9ff05d93615f2f54fbd2bb", + "sha256:1c9e4a5eb1bbc3675ee57bc31f8eea4cd7fb0cbcbe4912cf1cb2bf3b754f4a80", + "sha256:2025f913f2edb0272ef15d00b1f335ff8908c921c8eb2013536fcaf61f5a683d", + "sha256:25bad4196104761bc26b1dae9b57383826542ec689ff0042f7f4f4dd7a815cba", + "sha256:2692306d3d4cb32d2cceed1e47cebd6b1d2565c993d6d2eda8e6e6adf53301e6", + "sha256:272ab31228a9df857ab5df5d67936d8861464dc89c5d3fab35132626e9369379", + "sha256:2e8c0e79820cdd67978e1120983786422d279e07a381dbf89d03bbb23ec670a6", + "sha256:3062fd5c62df988cea9f2972c593f77fed1182bfddc5a3b12b1e606cb7aba99e", + "sha256:3436927d1794fa6763b89b60c896f9e3bd53212001026ebc9080d23f0c2733c1", + "sha256:35db06450272473eab4449e9c2ad9bc6a0a68dab8e81a0eae6b50d9c2838767e", + "sha256:392154d09bd4473b9d11351ab5d63391f3d5d24d752f27b3be7498b0ee2b5226", + "sha256:3cff6980fe7100242170092bb40d2b1cdad79502cd532fd26b12a2b8a5f9aee0", + "sha256:42c692b55a647a832025a4c048007034fe77b162b566ad537ce65ad824b12a84", + "sha256:44c9b9f1a245f3d0d202b1a8fa666a80b5ecbe4ad5d0859c0fb16a52d9763224", + "sha256:496b86f1fc9c81a1cd53d8842ef712e950a4611bba0c42d33366a7b91ba969ec", + "sha256:4bbd58eb5a2371bf160590f4262109f66b6043b0b991930693134cb617bc0169", + "sha256:4e3783a286d5a93a2921396d50ce45a909aa8f13eee964465012f110f0cbb611", + "sha256:4f3c7c19581d471af0e9cb49d928172cd8492cd78a2b7a4e82345d33662929bb", + "sha256:52c139b7ab3f0b15f9aad0a3fedef5a1f8c0b2bdc291d88639ca2c97d3682416", + "sha256:541280dde49ce74a4262c5e395b48ea1207e78454788887118c421cb4ffbfcac", + "sha256:5906f6a84b47f995cd1bf0aca1c72d591c55ee955f98074e93660d64dfc66eb9", + "sha256:6284a2005e4f8061c58c814b1600ad0074ccb0289fe61ea709655c5969877b70", + "sha256:6727a0d929ff0028b1ed8b3e7f8701670b1d7032f219110b55476bb60c390bfb", + "sha256:697f4742aa3f26c107ddcb2b1784a74fe40180014edbd9adaa574eac0529914c", + "sha256:6b9f64526286255735847aed0221b189486e0b9ed943446936e41b7e44b08783", + "sha256:6babcbf1e66e46052442f10833cfc4a0d3554d8276aa37af8531a83ed3c1a01d", + "sha256:6e7f1a8328eeec34c54f1d5968a708b50fc38d31e62ca8b0560e84a968fbf9a9", + "sha256:71f739f97f5f80627f1fee2331e63261355fd1e9a9cce0016394b6707ac3f4ec", + "sha256:76d06b721c2550c01a60e5d3093f417168658fb454e5dfd9a23570e9bffe39a1", + "sha256:77a04b84d01f0e12c66f16e69e92616442dc675bbe51b90bfb074b1e5d1c7fbd", + "sha256:97729e6828643f168a2a3f07848e1b1b94a366b13a9f5aba5484c2215724edc8", + "sha256:9a8723ccec4e564d4b9a79923246f7b9a8de4ec55fa03ec4ec804459dade3c4f", + "sha256:a5ffd45c6b93c23a8507e2f436983015c6457aa832496b6a095505ca2f63e8f1", + "sha256:a6f03f87fea579d55e0b690d28f5042ec1368650466520fbc400e7aeaf09e995", + "sha256:aac1d5fdc5378f6bac2c0c7ebe7635a6809f5b4376f6cf5d43243c1917a67087", + "sha256:ae82c5f168d2a39a5d69a12a69d4dc23837a43cf2ca99be60dfe59996ea6b113", + "sha256:bc7b667f8654376e9353dd93e55e12ce2a59fb6d8e29fce40de682273425e044", + "sha256:c1d7a31603c3483ac49c1726723b0934f88f2c011c660e6471e7bd735c2fa110", + "sha256:c534431153caffc7c495c3eddf7e6a6033e7f81d78385b4e41611b51e8870446", + "sha256:c93d52c3dc7b9c65e39473704988602300e3cc1bad08b5ab5b03ca98bbbc68c1", + "sha256:cbcc874f454ee51f158afd604a315f30c0e31dff1d5d5bf499fc529229d964dd", + "sha256:d3cacc6a665221108ecdf90517a8028d07a2783df3417d12dcfef1c517e67478", + "sha256:d712cefff15c712329113b01088ba71bbcef0f7ea58478ca0bbec63a824844cb", + "sha256:d7786b2fa7809bf835f830779ad285215a04da76293164bb6745796873f0942d", + "sha256:dc11b42fa61ff1e788dd095726a0aed6aad9c03d5c5984b54cb9e1e67b276aa5", + "sha256:dc4d5187ef4d53e0d4c8eaf530233685667844c5fb0b855fea71ae659017854b", + "sha256:f5440cdaf3099e7ab17a5a7065aed59aff8c8b079597b61c1f8be6f32fe60636", + "sha256:fa079995432037b5e2ef5ddbb270bcd2ded9f52b8e191a5de11fe59a00ea30d8", + "sha256:fbe6e8c0a9a7193ba10ee52977d4d5e7652957c1f56ccefed0701db8801a2a3b", + "sha256:fde5c7a9d9864d3e07992f66767a9817f24324f354caa3d8129735a3dc74f126" ], "index": "pypi", - "version": "==7.2.5" + "version": "==7.2.6" }, "cryptography": { "hashes": [ @@ -1000,7 +1000,7 @@ "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" ], - "index": "pypi", + "markers": "python_version >= '3.7'", "version": "==2.31.0" }, "rtreelib": { @@ -1094,19 +1094,19 @@ }, "typing-extensions": { "hashes": [ - "sha256:6ad00b63f849b7dcc313b70b6b304ed67b2b2963b3098a33efe18056b1a9a223", - "sha256:ff6b238610c747e44c268aa4bb23c8c735d665a63726df3f9431ce707f2aa768" + "sha256:06006244c70ac8ee83fa8282cb188f697b8db25bc8b4df07be1873c43897060c", + "sha256:3a8b36f13dd5fdc5d1b16fe317f5668545de77fa0b8e02006381fd49d731ab98" ], "markers": "python_version < '3.10'", - "version": "==4.6.0" + "version": "==4.6.2" }, "urllib3": { "hashes": [ - "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305", - "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42" + "sha256:8d36afa7616d8ab714608411b4a3b13e58f463aee519024578e062e141dce20f", + "sha256:8f135f6502756bde6b2a9b28989df5fbe87c9970cecaa69041edcce7f0589b14" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==1.26.15" + "version": "==1.26.16" }, "webencodings": { "hashes": [ @@ -1117,11 +1117,11 @@ }, "werkzeug": { "hashes": [ - "sha256:4866679a0722de00796a74086238bb3b98d90f423f05de039abb09315487254a", - "sha256:a987caf1092edc7523edb139edb20c70571c4a8d5eed02e0b547b4739174d091" + "sha256:1d5a58e0377d1fe39d061a5de4469e414e78ccb1e1e59c0f5ad6fa1c36c52b76", + "sha256:48e5e61472fee0ddee27ebad085614ebedb7af41e88f687aaf881afb723a162f" ], "index": "pypi", - "version": "==2.3.3" + "version": "==2.3.4" }, "wtforms": { "hashes": [ @@ -1182,19 +1182,19 @@ }, "boto3": { "hashes": [ - "sha256:d47a68a0ca6599e8711c7da670fbac24085d9d50cfb4f761204f154d2b6fae26", - "sha256:f0a78f94a7140b60960898fd86677e4e73cc96bd7f3e5c64fc5cc1818d04c7b8" + "sha256:152def2fcc9854dcc42383d2b53e2ed2c9ccb5ff6cc0f3ada20f1ab54418ede4", + "sha256:a5d6fdcaec863bc7ad2f8133ff9a926d6f06468b83b5fb631cd90bd33b709c45" ], "markers": "python_version >= '3.7'", - "version": "==1.26.138" + "version": "==1.26.141" }, "botocore": { "hashes": [ - "sha256:31edc237088c104f7a05887646bbec31d7459dd2e108fd90cbffa315902817e2", - "sha256:3d145f30d10a9c712acee48e7ce906c9456bb25fe50d477c9312c702ccfa50d1" + "sha256:b01d156c42765f3f437959e01a8c7f3cb0e29b24aa0b8f373498133408b2e3c7", + "sha256:e86e1633f98838317b9e1b5c874c4d85339b77f6b7e55c2a4d83913f6166f9ad" ], "markers": "python_version >= '3.7'", - "version": "==1.29.138" + "version": "==1.29.141" }, "cachecontrol": { "extras": [ @@ -1362,7 +1362,7 @@ "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df", "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab" ], - "markers": "python_version >= '3.7'", + "markers": "python_full_version >= '3.7.0'", "version": "==3.1.0" }, "cryptography": { @@ -1717,18 +1717,18 @@ }, "pip-audit": { "hashes": [ - "sha256:a4cb03f9e2896d626f5b153973d3ac0d32fdb18594d78d393b153c83bb8089b6", - "sha256:bee3748030c895488b4dd8a6196fa44f484da000cfd52d8fc64dfa3a2e121624" + "sha256:04fc0ad1727674181bda243a457af5a73038ee691dd9b8afc71f7e9292ce3912", + "sha256:7673bea690470024f1aec9be26055334cb987a530c6a431a31c347f66064e475" ], "index": "pypi", - "version": "==2.5.4" + "version": "==2.5.6" }, "pip-requirements-parser": { "hashes": [ "sha256:4659bc2a667783e7a15d190f6fccf8b2486685b6dba4c19c3876314769c57526", "sha256:b4fa3a7a0be38243123cf9d1f3518da10c51bdb165a2b2985566247f9155a7d3" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==32.0.1" }, "pluggy": { @@ -1892,7 +1892,7 @@ "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" ], - "index": "pypi", + "markers": "python_version >= '3.7'", "version": "==2.31.0" }, "requests-mock": { @@ -1916,7 +1916,7 @@ "sha256:2d11b9b8dd03868f09b4fffadc84a6a8cda574e40dc90821bd845720ebb8e89c", "sha256:69cdf53799e63f38b95b9bf9c875f8c90e78dd62b2f00c13a911c7a3b9fa4704" ], - "markers": "python_version >= '3.7'", + "markers": "python_full_version >= '3.7.0'", "version": "==13.3.5" }, "s3transfer": { @@ -1999,11 +1999,11 @@ }, "urllib3": { "hashes": [ - "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305", - "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42" + "sha256:8d36afa7616d8ab714608411b4a3b13e58f463aee519024578e062e141dce20f", + "sha256:8f135f6502756bde6b2a9b28989df5fbe87c9970cecaa69041edcce7f0589b14" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==1.26.15" + "version": "==1.26.16" }, "webencodings": { "hashes": [ @@ -2014,11 +2014,11 @@ }, "werkzeug": { "hashes": [ - "sha256:4866679a0722de00796a74086238bb3b98d90f423f05de039abb09315487254a", - "sha256:a987caf1092edc7523edb139edb20c70571c4a8d5eed02e0b547b4739174d091" + "sha256:1d5a58e0377d1fe39d061a5de4469e414e78ccb1e1e59c0f5ad6fa1c36c52b76", + "sha256:48e5e61472fee0ddee27ebad085614ebedb7af41e88f687aaf881afb723a162f" ], "index": "pypi", - "version": "==2.3.3" + "version": "==2.3.4" }, "xmltodict": { "hashes": [ diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index e789f7f5e..da12a9e8c 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -267,7 +267,7 @@ def test_choose_account_should_not_show_back_to_service_link_if_not_signed_in( @pytest.mark.parametrize('active', ( False, - pytest.param(True, marks=pytest.mark.xfail(raises=AssertionError)), + pytest.param(True), )) def test_choose_account_should_not_show_back_to_service_link_if_service_archived( client_request, @@ -283,7 +283,10 @@ def test_choose_account_should_not_show_back_to_service_link_if_service_archived page = client_request.get('main.choose_account') assert normalize_spaces(page.select_one('h1').text) == 'Choose service' - assert page.select_one('.navigation-service a') is None + if active: + assert page.select_one('.navigation-service a') is not None + else: + assert page.select_one('.navigation-service a') is None def test_should_not_show_back_to_service_if_user_doesnt_belong_to_service( diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index 497954970..2bb0eca14 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -262,64 +262,6 @@ def test_gps_can_create_own_organisations( ) -@pytest.mark.parametrize('organisation_type, organisation, expected_status', ( - ('nhs_local', None, 200), - ('nhs_gp', None, 403), - ('central', None, 403), - ('nhs_local', organisation_json(organisation_type='nhs_local'), 403), -)) -@pytest.mark.skip(reason='Update for TTS') -def test_nhs_local_can_create_own_organisations( - client_request, - mocker, - mock_get_service_organisation, - service_one, - organisation_type, - organisation, - expected_status, -): - mocker.patch('app.organisations_client.get_organisation', return_value=organisation) - mocker.patch( - 'app.models.organisation.AllOrganisations.client_method', - return_value=[ - organisation_json('t2', 'Trust 2', organisation_type='nhs_local'), - organisation_json('t1', 'Trust 1', organisation_type='nhs_local'), - organisation_json('gp1', 'GP 1', organisation_type='nhs_gp'), - organisation_json('c1', 'Central 1'), - ], - ) - service_one['organisation_type'] = organisation_type - - page = client_request.get( - '.add_organisation_from_nhs_local_service', - service_id=SERVICE_ONE_ID, - _expected_status=expected_status, - ) - - if expected_status == 403: - return - - assert normalize_spaces(page.select_one('main p').text) == ( - 'Which NHS Trust or Clinical Commissioning Group do you work for?' - ) - assert page.select_one('[data-module=live-search]')['data-targets'] == ( - '.govuk-radios__item' - ) - assert [ - ( - normalize_spaces(radio.select_one('label').text), - radio.select_one('input')['value'] - ) - for radio in page.select('.govuk-radios__item') - ] == [ - ('Trust 1', 't1'), - ('Trust 2', 't2'), - ] - assert normalize_spaces(page.select_one('.js-stick-at-bottom-when-scrolling button').text) == ( - 'Continue' - ) - - @pytest.mark.parametrize('data, expected_service_name', ( ( { @@ -398,33 +340,6 @@ def test_validation_of_gps_creating_organisations( assert expected_error in page.select_one('.govuk-error-message, .error-message').text -@pytest.mark.skip(reason='Update for TTS') -def test_nhs_local_assigns_to_selected_organisation( - client_request, - mocker, - service_one, - mock_get_organisation, - mock_update_service_organisation, -): - mocker.patch( - 'app.models.organisation.AllOrganisations.client_method', - return_value=[ - organisation_json(ORGANISATION_ID, 'Trust 1', organisation_type='nhs_local'), - ], - ) - service_one['organisation_type'] = 'nhs_local' - - client_request.post( - '.add_organisation_from_nhs_local_service', - service_id=SERVICE_ONE_ID, - _data={ - 'organisations': ORGANISATION_ID, - }, - _expected_status=302, - ) - mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID) - - @freeze_time("2020-02-20 20:20") def test_organisation_services_shows_live_services_and_usage( client_request, @@ -795,8 +710,8 @@ def test_manage_org_users_shows_no_link_for_cancelled_users( @pytest.mark.parametrize('number_of_users', ( - pytest.param(7, marks=pytest.mark.xfail), pytest.param(8), + pytest.param(800), )) def test_manage_org_users_should_show_live_search_if_more_than_7_users( client_request, @@ -839,6 +754,37 @@ def test_manage_org_users_should_show_live_search_if_more_than_7_users( ) == 'Search by name or email address' +@pytest.mark.parametrize('number_of_users', ( + pytest.param(3), + pytest.param(7), +)) +def test_manage_org_users_should_show_live_search_if_7_users_or_less( + client_request, + mocker, + mock_get_organisation, + active_user_with_permissions, + number_of_users, +): + mocker.patch( + 'app.models.user.OrganisationInvitedUsers.client_method', + return_value=[], + ) + mocker.patch( + 'app.models.user.OrganisationUsers.client_method', + return_value=[active_user_with_permissions] * number_of_users, + ) + + page = client_request.get( + '.manage_org_users', + org_id=ORGANISATION_ID, + ) + + with pytest.raises(expected_exception=TypeError): + assert page.select_one('div[data-module=live-search]')['data-targets'] == ( + ".user-list-item" + ) + + def test_edit_organisation_user_shows_the_delete_confirmation_banner( client_request, mock_get_organisation, @@ -993,7 +939,6 @@ def test_view_organisation_settings( ), pytest.param( create_active_user_with_permissions(), - marks=pytest.mark.xfail ), )) def test_update_organisation_settings( @@ -1011,21 +956,28 @@ def test_update_organisation_settings( mocker.patch('app.organisations_client.get_organisation_services', return_value=[]) client_request.login(user) + if user['email_address'] == 'platform@admin.gsa.gov': + expected_status = 302 + expected_redirect = url_for( + 'main.organisation_settings', + org_id=organisation_one['id'], + ) + else: + expected_status = 403 + expected_redirect = None client_request.post( endpoint, org_id=organisation_one['id'], _data=post_data, - _expected_status=302, - _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], - ), + _expected_status=expected_status, + _expected_redirect=expected_redirect, ) - mock_update_organisation.assert_called_once_with( - organisation_one['id'], - **expected_persisted, - ) + if user['email_address'] == 'platform@admin.gsa.gov': + mock_update_organisation.assert_called_once_with( + organisation_one['id'], + **expected_persisted, + ) def test_update_organisation_sector_sends_service_id_data_to_api_client( @@ -1143,7 +1095,6 @@ def test_view_organisation_domains( ), pytest.param( create_active_user_with_permissions(), - marks=pytest.mark.xfail ), )) def test_update_organisation_domains( @@ -1157,22 +1108,29 @@ def test_update_organisation_domains( user, ): client_request.login(user) + if user['email_address'] == 'platform@admin.gsa.gov': + expected_status = 302 + expected_redirect = url_for( + 'main.organisation_settings', + org_id=organisation_one['id'], + ) + else: + expected_status = 403 + expected_redirect = None client_request.post( 'main.edit_organisation_domains', org_id=ORGANISATION_ID, _data=post_data, - _expected_status=302, - _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], - ), + _expected_status=expected_status, + _expected_redirect=expected_redirect, ) - mock_update_organisation.assert_called_once_with( - ORGANISATION_ID, - **expected_persisted, - ) + if user['email_address'] == 'platform@admin.gsa.gov': + mock_update_organisation.assert_called_once_with( + ORGANISATION_ID, + **expected_persisted, + ) def test_update_organisation_domains_when_domain_already_exists( diff --git a/tests/app/main/views/service_settings/test_email_branding_requests.py b/tests/app/main/views/service_settings/test_email_branding_requests.py index ca3c1467c..305337e66 100644 --- a/tests/app/main/views/service_settings/test_email_branding_requests.py +++ b/tests/app/main/views/service_settings/test_email_branding_requests.py @@ -6,21 +6,15 @@ from notifications_utils.clients.zendesk.zendesk_client import ( NotifySupportTicket, ) -from app.utils.branding import NHS_EMAIL_BRANDING_ID from tests import sample_uuid from tests.conftest import ORGANISATION_ID, SERVICE_ONE_ID, normalize_spaces @pytest.mark.parametrize('organisation_type, expected_options', ( - ('nhs_central', [ - ('nhs', 'NHS'), - ('something_else', 'Something else'), - ]), ('other', [ ('something_else', 'Something else'), - ]) + ]), )) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_request_page_when_no_branding_is_set( service_one, client_request, @@ -77,7 +71,6 @@ def test_email_branding_request_page_shows_branding_if_set( assert page.find('iframe')['src'] == url_for('main.email_template', branding_style='some-random-branding') -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_request_page_back_link( client_request, ): @@ -104,13 +97,6 @@ def test_email_branding_request_page_back_link( 'federal', 'main.email_branding_govuk_and_org', ), - ( - { - 'options': 'organisation', - }, - 'federal', - 'main.email_branding_organisation', - ), ( { 'options': 'something_else', @@ -119,7 +105,6 @@ def test_email_branding_request_page_back_link( 'main.email_branding_something_else', ), )) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_request_submit( client_request, service_one, @@ -151,7 +136,6 @@ def test_email_branding_request_submit( ) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_request_submit_when_no_radio_button_is_selected( client_request, service_one, @@ -170,9 +154,7 @@ def test_email_branding_request_submit_when_no_radio_button_is_selected( @pytest.mark.parametrize('endpoint, expected_heading', [ ('main.email_branding_govuk_and_org', 'Before you request new branding'), - ('main.email_branding_organisation', 'When you request new branding'), ]) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_description_pages_for_org_branding( client_request, mocker, @@ -250,7 +232,6 @@ def test_email_branding_something_else_page(client_request, service_one): ) -@pytest.mark.skip(reason='Update for TTS') def test_get_email_branding_something_else_page_is_only_option(client_request, service_one): # should only have a "something else" option # so back button goes back to settings page @@ -268,7 +249,6 @@ def test_get_email_branding_something_else_page_is_only_option(client_request, s @pytest.mark.parametrize('endpoint', [ ('main.email_branding_govuk'), ('main.email_branding_govuk_and_org'), - # ('main.email_branding_nhs'), ('main.email_branding_organisation'), ]) def test_email_branding_pages_give_404_if_selected_branding_not_allowed( @@ -284,7 +264,6 @@ def test_email_branding_pages_give_404_if_selected_branding_not_allowed( ) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_govuk_submit( mocker, client_request, @@ -379,34 +358,6 @@ def test_email_branding_govuk_and_org_submit( ) -@pytest.mark.skip(reason='Update for TTS') -def test_email_branding_nhs_submit( - mocker, - client_request, - service_one, - organisation_one, - no_reply_to_email_addresses, - mock_get_email_branding, - single_sms_sender, - mock_update_service, -): - service_one['email_branding'] = sample_uuid() - service_one['organisation_type'] = 'nhs_local' - - page = client_request.post( - '.email_branding_nhs', - service_id=SERVICE_ONE_ID, - _follow_redirects=True, - ) - - mock_update_service.assert_called_once_with( - SERVICE_ONE_ID, - email_branding=NHS_EMAIL_BRANDING_ID, - ) - assert page.h1.text == 'Settings' - assert normalize_spaces(page.select_one('.banner-default').text) == 'You’ve updated your email branding' - - @pytest.mark.skip(reason='Update for TTS') def test_email_branding_organisation_submit( mocker, @@ -466,7 +417,6 @@ def test_email_branding_organisation_submit( ) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_something_else_submit( client_request, mocker, @@ -518,7 +468,6 @@ def test_email_branding_something_else_submit( ) -@pytest.mark.skip(reason='Update for TTS') def test_email_branding_something_else_submit_shows_error_if_textbox_is_empty( client_request, ): diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index 1b3502674..276dd973b 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -122,10 +122,6 @@ def test_service_setting_toggles_show( ({'active': True}, '.history', 2, 'Service history'), ({'active': False}, '.resume_service', 0, 'Resume service'), ({'active': False}, '.history', 1, 'Service history'), - pytest.param( - {'active': False}, '.archive_service', 2, 'Resume service', - marks=pytest.mark.xfail(raises=IndexError) - ) ]) def test_service_setting_link_toggles( get_service_settings_page, @@ -143,6 +139,26 @@ def test_service_setting_link_toggles( assert link['href'] == link_url +@pytest.mark.parametrize('service_fields, endpoint, index, text', [ + pytest.param( + {'active': False}, '.archive_service', 2, 'Resume service', + ) +]) +def test_service_setting_link_toggles_index_error( + get_service_settings_page, + service_one, + service_fields, + endpoint, + index, + text, +): + with pytest.raises(expected_exception=IndexError): + url_for(endpoint, service_id=service_one['id']) + service_one.update(service_fields) + page = get_service_settings_page() + page.select('.page-footer-link a')[index] + + @pytest.mark.parametrize('permissions,permissions_text,visible', [ ('sms', 'inbound SMS', True), ('inbound_sms', 'inbound SMS', False), # no sms parent permission diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 3d3ba51cd..5bc60db20 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -61,12 +61,6 @@ def mock_get_service_settings_page_common( 'Start text messages with service name On Change your settings for starting text messages with service name', 'Send international text messages Off Change your settings for sending international text messages', - # 'Label Value Action', - # 'Send emails On Change your settings for sending emails', - # 'Reply-to email addresses Not set Manage reply-to email addresses', - # 'Email branding GOV.UK Change email branding', - # 'Send files by email contact_us@gsa.gov Manage sending files by email', - # 'Receive text messages Off Change your settings for receiving text messages', ]), (create_platform_admin_user(), [ @@ -78,12 +72,6 @@ def mock_get_service_settings_page_common( 'Start text messages with service name On Change your settings for starting text messages with service name', 'Send international text messages Off Change your settings for sending international text messages', - # 'Label Value Action', - # 'Send emails On Change your settings for sending emails', - # 'Reply-to email addresses Not set Manage reply-to email addresses', - # 'Email branding GOV.UK Change email branding', - # 'Send files by email contact_us@gsa.gov Manage sending files by email', - # 'Receive text messages Off Change your settings for receiving text messages', 'Label Value Action', 'Live Off Change service status', @@ -221,12 +209,6 @@ def test_send_files_by_email_row_on_settings_page( 'Start text messages with service name On Change your settings for starting text messages with service name', 'Send international text messages On Change your settings for sending international text messages', - # 'Label Value Action', - # 'Send emails On Change your settings for sending emails', - # 'Reply-to email addresses test@example.com Manage reply-to email addresses', - # 'Email branding Organisation name Change email branding', - # 'Send files by email Not set up Manage sending files by email', - # 'Receive text messages On Change your settings for receiving text messages', ]), (['email', 'sms', 'email_auth'], [ @@ -238,12 +220,6 @@ def test_send_files_by_email_row_on_settings_page( 'Start text messages with service name On Change your settings for starting text messages with service name', 'Send international text messages Off Change your settings for sending international text messages', - # 'Label Value Action', - # 'Send emails On Change your settings for sending emails', - # 'Reply-to email addresses test@example.com Manage reply-to email addresses', - # 'Email branding Organisation name Change email branding', - # 'Send files by email Not set up Manage sending files by email' - # 'Receive text messages Off Change your settings for receiving text messages', ]), ]) @@ -619,8 +595,6 @@ def test_should_check_if_estimated_volumes_provided( 'reply_to_email_addresses,' 'expected_reply_to_checklist_item' ), [ - pytest.param(None, 0, [], '', marks=pytest.mark.xfail(raises=IndexError)), - pytest.param(0, 0, [], '', marks=pytest.mark.xfail(raises=IndexError)), (None, 1, [], 'Add a reply-to email address Not completed'), (None, 1, [{}], 'Add a reply-to email address Completed'), (1, 1, [], 'Add a reply-to email address Not completed'), @@ -674,6 +648,59 @@ def test_should_check_for_reply_to_on_go_live( mock_get_reply_to_email_addresses.assert_called_once_with(SERVICE_ONE_ID) +@pytest.mark.parametrize(( + 'volume_email,' + 'count_of_email_templates,' + 'reply_to_email_addresses,' + 'expected_reply_to_checklist_item' +), [ + (None, 0, [], ''), + (0, 0, [], ''), +]) +def test_should_check_for_reply_to_on_go_live_index_error( + client_request, + mocker, + service_one, + fake_uuid, + single_sms_sender, + volume_email, + count_of_email_templates, + reply_to_email_addresses, + expected_reply_to_checklist_item, + mock_get_invites_for_service, + mock_get_users_by_service, +): + mocker.patch( + 'app.service_api_client.get_service_templates', + return_value={'data': [ + create_template(template_type='email') + for _ in range(0, count_of_email_templates) + ]} + ) + + mocker.patch( + 'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses', + return_value=reply_to_email_addresses + ) + + for channel, volume in (('email', volume_email), ('sms', 0)): + mocker.patch( + 'app.models.service.Service.volume_{}'.format(channel), + create=True, + new_callable=PropertyMock, + return_value=volume, + ) + + with pytest.raises(expected_exception=IndexError): + page = client_request.get( + 'main.request_to_go_live', service_id=SERVICE_ONE_ID + ) + assert page.h1.text == 'Before you request to go live' + + checklist_items = page.select('.task-list .task-list-item') + assert normalize_spaces(checklist_items[3].text) == expected_reply_to_checklist_item + + @pytest.mark.parametrize(( 'count_of_users_with_manage_service,' 'count_of_invites_with_manage_service,' @@ -835,55 +862,49 @@ def test_request_to_go_live_redirects_if_service_already_live( 'sms_senders,' 'expected_sms_sender_checklist_item' ), [ - pytest.param( + ( 0, 'state', 0, [], '', - marks=pytest.mark.xfail(raises=IndexError) ), - pytest.param( + ( None, 'state', 0, [{'is_default': True, 'sms_sender': 'GOVUK'}], '', - marks=pytest.mark.xfail(raises=IndexError) ), - pytest.param( + ( 1, 'federal', 99, [{'is_default': True, 'sms_sender': 'GOVUK'}], '', - marks=pytest.mark.xfail(raises=IndexError) ), - pytest.param( + ( None, 'federal', 99, [{'is_default': True, 'sms_sender': 'GOVUK'}], '', - marks=pytest.mark.xfail(raises=IndexError) ), - pytest.param( + ( 1, 'federal', 99, [{'is_default': True, 'sms_sender': 'GOVUK'}], '', - marks=pytest.mark.xfail(raises=IndexError) ), - pytest.param( + ( 1, 'state', 1, [], 'Change your text message sender name Not completed', - marks=pytest.mark.xfail(raises=IndexError), ), - pytest.param( + ( 1, 'state', 1, @@ -892,7 +913,6 @@ def test_request_to_go_live_redirects_if_service_already_live( {'is_default': True, 'sms_sender': 'KUVOG'}, ], 'Change your text message sender name Completed', - marks=pytest.mark.xfail(raises=IndexError), ), ]) def test_should_check_for_sms_sender_on_go_live( @@ -935,15 +955,16 @@ def test_should_check_for_sms_sender_on_go_live( return_value=volume, ) - page = client_request.get( - 'main.request_to_go_live', service_id=SERVICE_ONE_ID - ) - assert page.h1.text == 'Before you request to go live' + with pytest.raises(expected_exception=IndexError): + page = client_request.get( + 'main.request_to_go_live', service_id=SERVICE_ONE_ID + ) + assert page.h1.text == 'Before you request to go live' - checklist_items = page.select('.task-list .task-list-item') - assert normalize_spaces(checklist_items[3].text) == expected_sms_sender_checklist_item + checklist_items = page.select('.task-list .task-list-item') + assert normalize_spaces(checklist_items[3].text) == expected_sms_sender_checklist_item - mock_get_sms_senders.assert_called_once_with(SERVICE_ONE_ID) + mock_get_sms_senders.assert_called_once_with(SERVICE_ONE_ID) def test_non_gov_user_is_told_they_cant_go_live( @@ -1702,8 +1723,6 @@ def test_and_more_hint_appears_on_settings_with_more_than_just_a_single_sender( "Reply-to email addresses test@example.com …and 2 more Manage reply-to email addresses" assert get_row(page, 'Text message senders') == \ "Text message senders Example …and 2 more Manage text message senders" - # assert get_row(page, 'Sender addresses') == \ - # "Sender addresses 1 Example Street …and 2 more Manage sender addresses" @pytest.mark.parametrize('sender_list_page, index, expected_output', [ @@ -2899,7 +2918,6 @@ def test_should_show_page_to_set_sms_allowance( ('0', 0), ('1', 1), ('250000', 250000), - pytest.param('foo', 'foo', marks=pytest.mark.xfail), ]) def test_should_set_sms_allowance( client_request, @@ -2929,6 +2947,34 @@ def test_should_set_sms_allowance( ) +@freeze_time("2017-04-01 11:09:00.061258") +@pytest.mark.parametrize('given_allowance, expected_api_argument', [ + pytest.param('foo', 'foo'), +]) +def test_should_set_sms_allowance_fails( + client_request, + platform_admin_user, + given_allowance, + expected_api_argument, + mock_get_free_sms_fragment_limit, + mock_create_or_update_free_sms_fragment_limit, +): + + with pytest.raises(expected_exception=AssertionError): + client_request.login(platform_admin_user) + client_request.post( + 'main.set_free_sms_allowance', + service_id=SERVICE_ONE_ID, + _data={ + 'free_sms_allowance': given_allowance, + }, + _expected_redirect=url_for( + 'main.service_settings', + service_id=SERVICE_ONE_ID, + ), + ) + + def test_should_show_page_to_set_message_limit( client_request, platform_admin_user, @@ -3147,8 +3193,6 @@ def test_switch_service_enable_international_sms( [create_platform_admin_user(), True], [create_platform_admin_user(), False], [create_active_user_with_permissions(), True], - pytest.param(create_active_user_with_permissions(), False, marks=pytest.mark.xfail), - pytest.param(create_active_user_no_settings_permission(), True, marks=pytest.mark.xfail), )) def test_archive_service_after_confirm( client_request, @@ -3186,12 +3230,41 @@ def test_archive_service_after_confirm( assert call(f"user-{sample_uuid()}") in redis_delete_mock.call_args_list +@pytest.mark.parametrize('user, is_trial_service', ( + pytest.param(create_active_user_with_permissions(), False), + pytest.param(create_active_user_no_settings_permission(), True), +)) +def test_archive_service_after_confirm_error( + client_request, + mocker, + mock_get_organisations, + mock_get_service_and_organisation_counts, + mock_get_organisations_and_services_for_user, + mock_get_users_by_service, + mock_get_service_templates, + service_one, + user, + is_trial_service, +): + service_one['restricted'] = is_trial_service + mocker.patch('app.service_api_client.post') + mocker.patch('app.main.views.service_settings.create_archive_service_event') + mocker.patch('app.notify_client.service_api_client.redis_client.delete') + mocker.patch('app.notify_client.service_api_client.redis_client.delete_by_pattern') + + with pytest.raises(expected_exception=AssertionError): + client_request.login(user) + client_request.post( + 'main.archive_service', + service_id=SERVICE_ONE_ID, + _follow_redirects=True, + ) + + @pytest.mark.parametrize('user, is_trial_service', ( [create_platform_admin_user(), True], [create_platform_admin_user(), False], [create_active_user_with_permissions(), True], - pytest.param(create_active_user_with_permissions(), False, marks=pytest.mark.xfail), - pytest.param(create_active_user_no_settings_permission(), True, marks=pytest.mark.xfail), )) def test_archive_service_prompts_user( client_request, @@ -3230,6 +3303,31 @@ def test_archive_service_prompts_user( assert mock_api.called is False +@pytest.mark.parametrize('user, is_trial_service', ( + pytest.param(create_active_user_with_permissions(), False), + pytest.param(create_active_user_no_settings_permission(), True), +)) +def test_archive_service_prompts_user_error( + client_request, + mocker, + single_reply_to_email_address, + service_one, + single_sms_sender, + mock_get_service_settings_page_common, + user, + is_trial_service, +): + mocker.patch('app.service_api_client.post') + service_one['restricted'] = is_trial_service + client_request.login(user) + + with pytest.raises(expected_exception=AssertionError): + client_request.get( + 'main.archive_service', + service_id=SERVICE_ONE_ID + ) + + def test_cant_archive_inactive_service( client_request, platform_admin_user, @@ -3251,7 +3349,6 @@ def test_cant_archive_inactive_service( @pytest.mark.parametrize('user', ( create_platform_admin_user(), - pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), )) def test_suspend_service_after_confirm( client_request, @@ -3275,9 +3372,31 @@ def test_suspend_service_after_confirm( mock_event.assert_called_once_with(service_id=SERVICE_ONE_ID, suspended_by_id=user['id']) +@pytest.mark.parametrize('user', ( + pytest.param(create_active_user_with_permissions()), +)) +def test_suspend_service_after_confirm_error( + client_request, + user, + mocker, +): + mocker.patch('app.service_api_client.post') + mocker.patch('app.main.views.service_settings.create_suspend_service_event') + with pytest.raises(expected_exception=AssertionError): + client_request.login(user) + client_request.post( + 'main.suspend_service', + service_id=SERVICE_ONE_ID, + _expected_redirect=url_for( + 'main.service_settings', + service_id=SERVICE_ONE_ID, + ), + ) + + @pytest.mark.parametrize('user', ( create_platform_admin_user(), - pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), + pytest.param(create_active_user_with_permissions()), )) def test_suspend_service_prompts_user( client_request, @@ -3291,6 +3410,12 @@ def test_suspend_service_prompts_user( mock_api = mocker.patch('app.service_api_client.post') client_request.login(user) + + if user['email_address'] != 'platform@admin.gsa.gov': + with pytest.raises(expected_exception=AssertionError): + client_request.get('main.suspend_service', service_id=service_one['id']) + return + page = client_request.get('main.suspend_service', service_id=service_one['id']) assert 'This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?' in \ @@ -3319,7 +3444,7 @@ def test_cant_suspend_inactive_service( @pytest.mark.parametrize('user', ( create_platform_admin_user(), - pytest.param(create_active_user_with_permissions(), marks=pytest.mark.xfail), + create_active_user_with_permissions(), )) def test_resume_service_after_confirm( mocker, @@ -3332,6 +3457,14 @@ def test_resume_service_after_confirm( mock_event = mocker.patch('app.main.views.service_settings.create_resume_service_event') client_request.login(user) + if user['email_address'] != "platform@admin.gsa.gov": + client_request.post( + 'main.resume_service', + service_id=SERVICE_ONE_ID, + _expected_status=403, + ) + return + client_request.post( 'main.resume_service', service_id=SERVICE_ONE_ID, @@ -3530,20 +3663,6 @@ def test_send_files_by_email_contact_details_does_not_update_invalid_contact_det @pytest.mark.parametrize('endpoint, permissions, expected_p', [ - # ( - # 'main.service_set_inbound_sms', - # ['sms'], - # ( - # 'Contact us if you want to be able to receive text messages from your users.' - # ) - # ), - # ( - # 'main.service_set_inbound_sms', - # ['sms', 'inbound_sms'], - # ( - # 'Your service can receive text messages sent to 2028675301.' - # ) - # ), ( 'main.service_set_auth_type', [], @@ -3771,7 +3890,6 @@ def test_update_service_organisation_does_not_update_if_same_value( @pytest.mark.skip(reason="Email currently deactivated") @pytest.mark.parametrize('single_branding_option, expected_href', [ (True, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding/something-else'), - # (False, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding'), ]) def test_service_settings_links_to_branding_request_page_for_emails( service_one, @@ -3785,10 +3903,6 @@ def test_service_settings_links_to_branding_request_page_for_emails( # should only have a "something else" option # so we go straight to that form service_one['organisation_type'] = 'other' - # else: - # # expect to have a "NHS" option as well as the - # # fallback one, so ask user to choose - # service_one['organisation_type'] = 'nhs_central' page = client_request.get( '.service_settings', service_id=SERVICE_ONE_ID diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 519218758..d9f0e1825 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -239,14 +239,13 @@ def test_css_is_served_from_correct_path(client_request): ][index]) -@pytest.mark.skip(reason="Update for TTS") def test_resources_that_use_asset_path_variable_have_correct_path(client_request): page = client_request.get('main.documentation') # easy static page logo_svg_fallback = page.select_one('.govuk-header__logotype-fallback-image') - assert logo_svg_fallback['src'].startswith('https://static.example.com/images/govuk-logotype.png') + assert logo_svg_fallback['src'].startswith('https://static.example.com/images/email-template/us-flag.png') @pytest.mark.parametrize('extra_args, email_branding_retrieved', ( diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index a792e0880..c6e43071d 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -245,16 +245,19 @@ def test_should_show_job_with_sending_limit_exceeded_status( )), # Just started (datetime(2020, 1, 10, 0, 0, 0), datetime(2020, 1, 10, 0, 0, 1), ( - 'No messages to show yet…' + 'No messages to show yet…' )), # Created a while ago, just started (datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 10, 0, 0, 1), ( - 'No messages to show yet…' + 'No messages to show yet…' )), # Created a while ago, started just within the last 24h - (datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 9, 6, 0, 1), ( - 'No messages to show yet…' - )), + # TODO -- fails locally, should pass, tech debt due to timezone changes, re-evaluate after UTC changes + pytest.param( + datetime(2020, 1, 1, 0, 0, 0), + datetime(2020, 1, 9, 6, 0, 1), + ('No messages to show yet…'), + ), # Created a while ago, started exactly 24h ago # --- # It doesn’t matter that 24h (1 day) and 7 days (the service’s data diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 0987e85e5..8ade6f3c9 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -191,7 +191,7 @@ def test_should_show_change_details_link( @pytest.mark.parametrize('number_of_users', ( - pytest.param(7, marks=pytest.mark.xfail), + pytest.param(7), pytest.param(8), )) def test_should_show_live_search_if_more_than_7_users( @@ -213,6 +213,13 @@ def test_should_show_live_search_if_more_than_7_users( page = client_request.get('main.manage_users', service_id=SERVICE_ONE_ID) + if number_of_users == 7: + with pytest.raises(expected_exception=TypeError): + assert page.select_one('div[data-module=live-search]')['data-targets'] == ( + ".user-list-item" + ) + return + assert page.select_one('div[data-module=live-search]')['data-targets'] == ( ".user-list-item" ) diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 467a5c149..6f087dbbc 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -2172,9 +2172,7 @@ def test_check_messages_shows_trial_mode_error( @pytest.mark.parametrize('uploaded_file_name', ( pytest.param('applicants.ods'), # normal job - pytest.param('thisisatest.csv', marks=pytest.mark.xfail), # different template version pytest.param('send_me_later.csv'), # should look at scheduled job - pytest.param('full_of_regret.csv', marks=pytest.mark.xfail), # job is cancelled )) def test_warns_if_file_sent_already( client_request, @@ -2215,6 +2213,51 @@ def test_warns_if_file_sent_already( mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID, limit_days=0) +@pytest.mark.parametrize('uploaded_file_name', ( + pytest.param('thisisatest.csv'), # different template version + pytest.param('full_of_regret.csv'), # job is cancelled +)) +def test_warns_if_file_sent_already_errors( + client_request, + mock_get_users_by_service, + mock_get_live_service, + mock_get_service_template, + mock_has_permissions, + mock_get_service_statistics, + mock_get_job_doesnt_exist, + mock_get_jobs, + fake_uuid, + mocker, + uploaded_file_name, +): + mocker.patch('app.main.views.send.s3download', return_value=( + 'phone number,\n2028675209' + )) + mocker.patch( + 'app.main.views.send.get_csv_metadata', + return_value={'original_file_name': uploaded_file_name}, + ) + # Should be botocore.errorfactory.NoSuchKey but for some reason can't use that + with pytest.raises(expected_exception=Exception): + page = client_request.get( + 'main.check_messages', + service_id=SERVICE_ONE_ID, + template_id="5d729fbd-239c-44ab-b498-75a985f3198f", + upload_id=fake_uuid, + original_file_name=uploaded_file_name, + _test_page_title=False, + ) + + assert normalize_spaces( + page.select_one('.banner-dangerous').text + ) == ( + 'These messages have already been sent today ' + 'If you need to resend them, rename the file and upload it again.' + ) + + mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID, limit_days=0) + + def test_check_messages_column_error_doesnt_show_optional_columns( mocker, client_request, diff --git a/tests/app/main/views/test_template_folders.py b/tests/app/main/views/test_template_folders.py index 0eff0016e..bbc8d089d 100644 --- a/tests/app/main/views/test_template_folders.py +++ b/tests/app/main/views/test_template_folders.py @@ -985,14 +985,6 @@ def test_delete_folder( pytest.param( create_active_user_with_permissions() ), - pytest.param( - create_active_user_view_permissions(), - marks=pytest.mark.xfail(raises=AssertionError) - ), - pytest.param( - create_active_caseworking_user(), - marks=pytest.mark.xfail(raises=AssertionError) - ), ]) def test_should_show_checkboxes_for_selecting_templates( client_request, @@ -1022,6 +1014,43 @@ def test_should_show_checkboxes_for_selecting_templates( assert TEMPLATE_ONE_ID not in checkboxes[index]['id'] +@pytest.mark.parametrize('user', [ + pytest.param( + create_active_user_view_permissions(), + ), + pytest.param( + create_active_caseworking_user(), + ), +]) +def test_should_show_checkboxes_for_selecting_templates_assertion_error( + client_request, + mocker, + service_one, + mock_get_service_templates, + mock_get_template_folders, + mock_has_no_jobs, + mock_get_no_api_keys, + user, +): + with pytest.raises(expected_exception=AssertionError): + client_request.login(user) + + page = client_request.get( + 'main.choose_template', + service_id=SERVICE_ONE_ID, + ) + checkboxes = page.select('input[name=templates_and_folders]') + + assert len(checkboxes) == 4 + + assert checkboxes[0]['value'] == TEMPLATE_ONE_ID + assert checkboxes[0]['id'] == 'templates-or-folder-{}'.format(TEMPLATE_ONE_ID) + + for index in (1, 2, 3): + assert checkboxes[index]['value'] != TEMPLATE_ONE_ID + assert TEMPLATE_ONE_ID not in checkboxes[index]['id'] + + @pytest.mark.parametrize('user', [ create_active_user_view_permissions(), create_active_caseworking_user(), diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 87ffd25c2..f234e99ca 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -352,11 +352,11 @@ def test_all_endpoints_are_covered(navigation_instance): navigation_instances, ids=(x.__class__.__name__ for x in navigation_instances) ) -@pytest.mark.xfail(raises=KeyError) def test_raises_on_invalid_navigation_item( client_request, navigation_instance ): - navigation_instance.is_selected('foo') + with pytest.raises(expected_exception=KeyError): + navigation_instance.is_selected('foo') @pytest.mark.parametrize('endpoint, selected_nav_item', [ diff --git a/tests/app/utils/test_user.py b/tests/app/utils/test_user.py index 6a6378911..ed4d9c1ae 100644 --- a/tests/app/utils/test_user.py +++ b/tests/app/utils/test_user.py @@ -6,10 +6,6 @@ from app.utils.user import user_has_permissions @pytest.mark.parametrize('permissions', ( - pytest.param([ - # Route has a permission which the user doesn’t have - 'send_messages' - ], marks=pytest.mark.xfail(raises=Forbidden)), [ # Route has one of the permissions which the user has 'manage_service' @@ -45,6 +41,32 @@ def test_permissions( index() +@pytest.mark.parametrize('permissions', ( + [ + # Route has a permission which the user doesn’t have + 'send_messages' + ], +)) +def test_permissions_forbidden( + client_request, + permissions, + api_user_active, +): + request.view_args.update({'service_id': 'foo'}) + + api_user_active['permissions'] = {'foo': ['manage_users', 'manage_templates', 'manage_settings']} + api_user_active['services'] = ['foo', 'bar'] + + client_request.login(api_user_active) + + @user_has_permissions(*permissions) + def index(): + pass + + with pytest.raises(expected_exception=Forbidden): + index() + + def test_restrict_admin_usage( client_request, platform_admin_user,