ispusage 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/ispusage/fetchers/iinet.rb +1 -1
- data/spec/fetchers/iinet_spec.rb +2 -2
- data/spec/fetchers/internode_spec.rb +32 -2
- data/spec/fixtures/{auiinet_single_account.xml → au_iinet/single_account.xml} +1 -1
- data/spec/fixtures/{auinternode_home.xml → au_internode/home.xml} +0 -0
- data/spec/fixtures/{auinternode_home_usage.xml → au_internode/home_usage.xml} +0 -0
- data/spec/fixtures/au_internode/home_usage_overlimit.xml +2 -0
- metadata +6 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -13,7 +13,7 @@ class IspUsage
|
|
13
13
|
def fetch_usage
|
14
14
|
xml = open("https://toolbox.iinet.net.au/cgi-bin/new/volume_usage_xml.cgi?action=login&username=#{@username}&password=#{@password}")
|
15
15
|
doc = Nokogiri::XML(xml)
|
16
|
-
used = doc.search("/ii_feed[1]/volume_usage[1]/expected_traffic_types[1]/type[1]/@used").text.to_i /
|
16
|
+
used = doc.search("/ii_feed[1]/volume_usage[1]/expected_traffic_types[1]/type[1]/@used").text.to_i / 998315 #best I can figure iinet uses base 2 and base 10 bytes
|
17
17
|
quota = doc.search("/ii_feed[1]/volume_usage[1]/expected_traffic_types[1]/type[1]/quota_allocation[1]").text.to_i
|
18
18
|
self.usage_periods << UsagePeriod.new(:used => used, :quota => quota)
|
19
19
|
end
|
data/spec/fetchers/iinet_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe IspUsage::Fetchers::AUIinet do
|
4
4
|
describe "single usage period" do
|
5
5
|
before do
|
6
|
-
fixture = File.read(File.dirname(__FILE__) + '/../fixtures/
|
6
|
+
fixture = File.read(File.dirname(__FILE__) + '/../fixtures/au_iinet/single_account.xml')
|
7
7
|
FakeWeb.register_uri(:get, 'https://toolbox.iinet.net.au/cgi-bin/new/volume_usage_xml.cgi?action=login&username=user&password=password', :body => fixture)
|
8
8
|
options = {:username => 'user', :password => 'password'}
|
9
9
|
@usage = IspUsage::Fetchers::AUIinet.new(options)
|
@@ -11,7 +11,7 @@ describe IspUsage::Fetchers::AUIinet do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return usage correctly" do
|
14
|
-
@usage.usage_periods.first.used.should ==
|
14
|
+
@usage.usage_periods.first.used.should == 45106
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return quota correctly" do
|
@@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe IspUsage::Fetchers::AUInternode do
|
4
4
|
describe "single usage period" do
|
5
5
|
before do
|
6
|
-
services = File.read(File.dirname(__FILE__) + '/../fixtures/
|
6
|
+
services = File.read(File.dirname(__FILE__) + '/../fixtures/au_internode/home.xml')
|
7
7
|
FakeWeb.register_uri(:get, 'https://user:password@customer-webtools-api.internode.on.net/api/v1.5/', :body => services)
|
8
|
-
service = File.read(File.dirname(__FILE__) + '/../fixtures/
|
8
|
+
service = File.read(File.dirname(__FILE__) + '/../fixtures/au_internode/home_usage.xml')
|
9
9
|
FakeWeb.register_uri(:get, 'https://user:password@customer-webtools-api.internode.on.net/api/v1.5/1234567/usage', :body => service)
|
10
10
|
|
11
11
|
|
@@ -21,5 +21,35 @@ describe IspUsage::Fetchers::AUInternode do
|
|
21
21
|
it "should return quota correctly" do
|
22
22
|
@usage.usage_periods.first.quota.should == 50000
|
23
23
|
end
|
24
|
+
|
25
|
+
it "should return total correctly" do
|
26
|
+
@usage.usage_periods.first.total.should == 50000
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "single usage period over limit" do
|
31
|
+
before do
|
32
|
+
services = File.read(File.dirname(__FILE__) + '/../fixtures/au_internode/home.xml')
|
33
|
+
FakeWeb.register_uri(:get, 'https://user:password@customer-webtools-api.internode.on.net/api/v1.5/', :body => services)
|
34
|
+
service = File.read(File.dirname(__FILE__) + '/../fixtures/au_internode/home_usage_overlimit.xml')
|
35
|
+
FakeWeb.register_uri(:get, 'https://user:password@customer-webtools-api.internode.on.net/api/v1.5/1234567/usage', :body => service)
|
36
|
+
|
37
|
+
|
38
|
+
options = {:username => 'user', :password => 'password'}
|
39
|
+
@usage = IspUsage::Fetchers::AUInternode.new(options)
|
40
|
+
@usage.fetch_usage
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return usage correctly" do
|
44
|
+
@usage.usage_periods.first.used.should == 50013
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return quota correctly" do
|
48
|
+
@usage.usage_periods.first.quota.should == 50000
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return total correctly" do
|
52
|
+
@usage.usage_periods.first.total.should == 50013
|
53
|
+
end
|
24
54
|
end
|
25
55
|
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<days_remaining>22</days_remaining>
|
11
11
|
</quota_reset>
|
12
12
|
<expected_traffic_types>
|
13
|
-
<type classification="anytime" used="
|
13
|
+
<type classification="anytime" used="45030021786">
|
14
14
|
<name>non-free</name>
|
15
15
|
<quota_allocation>100000</quota_allocation>
|
16
16
|
<is_shaped speed="0">false</is_shaped>
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ispusage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Harper
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-19 00:00:00 +10:00
|
13
13
|
default_executable: ispusage
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -48,9 +48,10 @@ files:
|
|
48
48
|
- spec/fetchers/fetcher_spec.rb
|
49
49
|
- spec/fetchers/iinet_spec.rb
|
50
50
|
- spec/fetchers/internode_spec.rb
|
51
|
-
- spec/fixtures/
|
52
|
-
- spec/fixtures/
|
53
|
-
- spec/fixtures/
|
51
|
+
- spec/fixtures/au_iinet/single_account.xml
|
52
|
+
- spec/fixtures/au_internode/home.xml
|
53
|
+
- spec/fixtures/au_internode/home_usage.xml
|
54
|
+
- spec/fixtures/au_internode/home_usage_overlimit.xml
|
54
55
|
- spec/ispusage_spec.rb
|
55
56
|
- spec/spec.opts
|
56
57
|
- spec/spec_helper.rb
|