예제 #1
0
    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())
예제 #2
0
    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
예제 #3
0
    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})
예제 #4
0
    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] == [])
예제 #5
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'})
예제 #6
0
    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}
예제 #7
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"}