Beispiel #1
0
    def test_usermod(self):
        args = self.Arguments(username="******", passw="goofer", apikey="wtf")

        resp = self.Response("hihi")
        with mock.patch("requests.post", return_value=resp) as mock_reqs:
            r = usermod(args)
            # returns the text we provided
            self.assertEqual(r, resp.text)
            mock_reqs.assert_called_with(produce_url(
                ["admin", "usermod"], [args.username, args.passw]),
                                         data={},
                                         headers=self._get_header(args.apikey))
Beispiel #2
0
    def test_users(self):
        args = self.Arguments(users="billy", apikey="koko")

        resp = self.Response("okok")
        with mock.patch("requests.get", return_value=resp) as mock_reqs:
            r = users(args)

            self.assertEqual(r, resp.text)
            mock_reqs.assert_called_with(produce_url(["admin", "users"],
                                                     [args.users]),
                                         data={},
                                         headers=self._get_header(args.apikey))
Beispiel #3
0
    def test_login(self):
        args = self.Arguments(username="******", passw="sio")

        resp = self.Response({"token": "koko"})
        with mock.patch("requests.post", return_value=resp) as mock_reqs:
            r = login(args)
            self.assertEqual(r, resp.text)
            mock_reqs.assert_called_with(produce_url(["login"]),
                                         data={
                                             'username': args.username,
                                             'password': args.passw
                                         },
                                         headers=self._get_header())
Beispiel #4
0
    def test_login(self):
        args = self.Arguments(point='1',
                              datefrom='2020-03-30 23:49:39',
                              dateto='2020-03-30 23:49:39',
                              format="json",
                              apikey="koko")

        resp = self.Response("okok")
        with mock.patch("requests.get", return_value=resp) as mock_reqs:
            r = sessions_per_point(args)
            self.assertEqual(r, resp.text)
            mock_reqs.assert_called_with(produce_url(
                ["SessionsPerPoint"], [args.point, args.datefrom, args.dateto],
                args.format),
                                         data={},
                                         headers=self._get_header(args.apikey))
Beispiel #5
0
def sessions_per_ev(args):
    url = produce_url(["SessionsPerEV"], [args.ev, args.datefrom, args.dateto],
                      args.format)
    response = place_request("get", url, token=args.apikey)
    return response.text
Beispiel #6
0
def healthcheck(args):
    url = produce_url(["admin", "healthcheck"])
    response = place_request("get", url)
    return response.text
Beispiel #7
0
def resetsessions(args):
    url = produce_url(["admin", "resetsessions"])
    response = place_request("delete", url)
    return response.text
Beispiel #8
0
def logout(args):
    url = produce_url(['logout'])
    response = place_request("post", url, token=args.apikey)
    delete_token_file()
    return response.text