def test_register(self): with patch('requests.post') as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client('test') with patch('requests.post') as m: m.return_value = MagicMock() m.return_value.text = '{}' c.register() assert (not c._am_registered())
def test_register(self): with patch("requests.post") as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client("test") with patch("requests.post") as m: m.return_value = MagicMock() m.return_value.text = "{}" c.register() assert not c._am_registered
def test_samplePredict1(self): with patch('requests.post') as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client('test') with patch('requests.post') as mock: c.register = lambda: None mock.return_value = MagicMock() mock.return_value.text = '{"id":1}' c._samplePredict1() assert (c._my_competitions[0] == {'id': 1})
def test_start_competition(self): with patch('requests.post') as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client('test') with patch('requests.post') as mock: c.register = lambda: None mock.return_value = MagicMock() mock.return_value.text = '[]' c.start_competition(competition) assert (c._my_competitions[0] == [])
def test_users(self): with patch('requests.post') as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client('test') with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.text = ujson.dumps({'test': 'test'}) c.register = lambda: None x = c.users() assert (x == {'test': 'test'})
def test_sampleClassify(self): with patch("requests.post") as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client("test") with patch("requests.post") as mock: c.register = lambda: None mock.return_value = MagicMock() mock.return_value.text = '{"id":1}' c._sampleClassify1() assert c._my_competitions[0] == {"id": 1}
def test_users(self): with patch("requests.post") as m: m.return_value = MagicMock() m.return_value.text = '{"id":1}' c = Client("test") with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.text = ujson.dumps({"test": "test"}) c.register = lambda: None x = c.users() assert x == {"test": "test"}