File: test_admin.py

package info (click to toggle)
python-pysolr 3.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: python: 2,050; sh: 166; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 1,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import unittest

from pysolr import SolrCoreAdmin


class SolrCoreAdminTestCase(unittest.TestCase):
    def setUp(self):
        super(SolrCoreAdminTestCase, self).setUp()
        self.solr_admin = SolrCoreAdmin("http://localhost:8983/solr/admin/cores")

    def test_status(self):
        self.assertIn('name="defaultCoreName"', self.solr_admin.status())
        self.assertIn('<int name="status">', self.solr_admin.status(core="core0"))

    def test_create(self):
        self.assertIn('<int name="status">0</int>', self.solr_admin.create("wheatley"))

    def test_reload(self):
        self.assertIn('<int name="status">0</int>', self.solr_admin.reload("wheatley"))

    def test_rename(self):
        self.solr_admin.create("wheatley")
        self.assertIn(
            '<int name="status">0</int>', self.solr_admin.rename("wheatley", "rick")
        )

    def test_swap(self):
        self.solr_admin.create("wheatley")
        self.solr_admin.create("rick")
        self.assertIn(
            '<int name="status">0</int>', self.solr_admin.swap("wheatley", "rick")
        )

    def test_unload(self):
        self.solr_admin.create("wheatley")
        self.assertIn('<int name="status">0</int>', self.solr_admin.unload("wheatley"))

    def test_load(self):
        self.assertRaises(NotImplementedError, self.solr_admin.load, "wheatley")