Exemplo n.º 1
0
 def test_create_node(self):
     self.mock_api_client(200)
     self.mock_node_create(self.expected_node, 201)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     data = publisher._create_node(self.api_client, publish_data)  # pylint: disable=protected-access
     self.assertEqual(data, self.expected_node['id'])
Exemplo n.º 2
0
 def test_create_node_failed(self):
     self.mock_api_client(200)
     self.mock_node_create({}, 500)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     with self.assertRaises(ProgramPublisherException):
         publisher._create_node(self.api_client, publish_data)  # pylint: disable=protected-access
Exemplo n.º 3
0
 def test_create_node_failed(self):
     self.mock_api_client(200)
     self.mock_node_create({}, 500)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     with self.assertRaises(ProgramPublisherException):
         publisher._create_node(self.api_client, publish_data)  # pylint: disable=protected-access
Exemplo n.º 4
0
 def test_edit_node(self):
     self.mock_api_client(200)
     self.mock_node_edit(200)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     publisher._edit_node(self.api_client, self.node_id, publish_data)  # pylint: disable=protected-access
     self.assert_responses_call_count(5)
Exemplo n.º 5
0
 def test_edit_node(self):
     self.mock_api_client(200)
     self.mock_node_edit(200)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     publisher._edit_node(self.api_client, self.nid, publish_data)  # pylint: disable=protected-access
     self.assert_responses_call_count(4)
Exemplo n.º 6
0
 def test_create_node(self):
     self.mock_api_client(200)
     expected = {'list': [{'nid': self.nid}]}
     self.mock_node_create(expected, 201)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     data = publisher._create_node(self.api_client, publish_data)  # pylint: disable=protected-access
     self.assertEqual(data, expected)
Exemplo n.º 7
0
 def test_create_node(self):
     self.mock_api_client(200)
     expected = {
         'list': [{
             'nid': self.nid
         }]
     }
     self.mock_node_create(expected, 201)
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     data = publisher._create_node(self.api_client, publish_data)  # pylint: disable=protected-access
     self.assertEqual(data, expected)
Exemplo n.º 8
0
 def test_get_node_data(self):
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     expected = {
         'type': str(self.program.type).lower(),
         'title': self.program.title,
         'field_uuid': str(self.program.uuid),
         'uuid': str(self.program.uuid),
         'author': {
             'id': self.user_id,
         },
         'status': 1 if self.program.status == ProgramStatus.Active else 0
     }
     self.assertDictEqual(publish_data, expected)
Exemplo n.º 9
0
 def test_get_node_data(self):
     publisher = MarketingSitePublisher()
     publish_data = publisher._get_node_data(self.program, self.user_id)  # pylint: disable=protected-access
     expected = {
         'type': str(self.program.type).lower(),
         'title': self.program.title,
         'field_uuid': str(self.program.uuid),
         'uuid': str(self.program.uuid),
         'author': {
             'id': self.user_id,
         },
         'status': 1 if self.program.status == ProgramStatus.Active else 0
     }
     self.assertDictEqual(publish_data, expected)