#85 Mock fedmsgshim.publish to prevent need for MQ to run tests
Closed 3 years ago by bcotton. Opened 4 years ago by nerdsville.
nerdsville/elections feature/js-mock_fed_messaging  into  develop

file modified
+10 -1
@@ -32,7 +32,7 @@ 

  from datetime import timedelta

  

  import flask

- from mock import patch, MagicMock

+ from mock import patch, Mock, MagicMock

  

  sys.path.insert(0, os.path.join(os.path.dirname(

      os.path.abspath(__file__)), '..'))
@@ -69,6 +69,7 @@ 

                  self.assertEqual(output.status_code, 200)

                  self.assertTrue('Candidates <span class="label label-pill label-default">3</span>' in output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_no_cla(self):

          """ Test the admin_new_election function. """

          self.setup_db()
@@ -85,6 +86,7 @@ 

                  output = self.app.get('/admin/new')

                  self.assertEqual(output.status_code, 403)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_new_election(self):

          """ Test the admin_new_election function. """

          self.setup_db()
@@ -379,6 +381,7 @@ 

                      'name="max_votes" type="text" '

                      'value="">', output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_edit_election(self):

          """ Test the admin_edit_election function. """

          user = FakeUser(
@@ -522,6 +525,7 @@ 

                          'value="2">', output_text)

                  self.assertTrue('Candidates <span class="label label-pill label-default">3</span>' in output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_edit_election_admin_groups(self):

          """ Test the admin_edit_election function when editing admin groups.

          """
@@ -642,6 +646,7 @@ 

                      'name="admin_grp" type="text" '

                      'value="sysadmin-main">', output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_edit_election_legal_voters(self):

          """ Test the admin_edit_election function when editing legal voters.

          """
@@ -747,6 +752,7 @@ 

                      'name="lgl_voters" type="text" '

                      'value="sysadmin-main">', output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_add_candidate(self):

          """ Test the admin_add_candidate function. """

          user = FakeUser(
@@ -839,6 +845,7 @@ 

                      in output_text)

                  self.assertTrue('Candidates <span class="label label-pill label-default">4</span>' in output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_add_multi_candidate(self):

          """ Test the admin_add_multi_candidate function. """

          user = FakeUser(
@@ -929,6 +936,7 @@ 

                      in output_text)

                  self.assertTrue('Candidates <span class="label label-pill label-default">6</span>' in output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_edit_candidate(self):

          """ Test the admin_edit_candidate function. """

          user = FakeUser(
@@ -1040,6 +1048,7 @@ 

                  self.assertTrue('Candidates <span class="label label-pill label-default">3</span>' in output_text)

                  self.assertTrue('<div class="list-group-item">Toshio' in output_text)

  

+     @patch("fedora_elections.fedmsgshim.publish", Mock())

      def test_admin_delete_candidate(self):

          """ Test the admin_delete_candidate function. """

          user = FakeUser(

no initial comment

rebased onto 8cb41ae

4 years ago

I think this may also be achieved via: https://pagure.io/elections/pull-request/90 which adds message schemas and checks that the expected messages were sent.

I’ll check and verify that tests run now based on those now merged changes. I updated my email for FAS so I should get notifications to my email now :)

This PR has conflicts and is allegedly fixed in #90, so I'm going to close this for now. Sorry, @nerdsville, but I appreciate the contribution!

Pull-Request has been closed by bcotton

3 years ago
Metadata